package org.example.demoarticle.exception;


import org.example.demoarticle.pojo.ResultByLogin;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(Exception.class)
    public ResultByLogin handleException(Exception e) {
        e.printStackTrace();
        if(e.getMessage()!=null) {
            return ResultByLogin.error(e.getMessage());
        }
        return ResultByLogin.error("操作失败");
    }
}
